#include <bits/stdc++.h>
using namespace std;
int main() {
  string password;
  cin >> password;

  int total = 0, waiting = 0;
  for (int i = 1; i <= 10; i++) {
    total += waiting;
    string s;
    cin >> s;
    if (s == password) {
      cout << total << endl;
      return 0;
    }
    if (i >= 3)
      waiting = max(1, waiting * 2);
  }

  cout << "Locked" << endl;

  return 0;
}           